package com.chengqj.observer;

import java.util.Vector;

/**
 * @program: pattern
 * @description: 具体主题角色
 * @author: chengqj
 * @create: 2018-08-03 10:14
 **/
public class ConreateSubject implements Subject {
    private Vector observersVector = new java.util.Vector();

    @Override
    public void attach(Observer obs) {
        observersVector.addElement(obs);
    }

    @Override
    public void notifyObservers() {
        for (int i=0;i<observersVector.size();i++){
            Observer obs = (Observer) observersVector.get(i);
            obs.update();
        }
    }

    public static void main(String[] args) {
        ConreateSubject subject = new ConreateSubject();
        subject.attach(new ConreateObserver());
        subject.notifyObservers();
    }
}
